package com.crm.custinfo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.crm.custinfo.domain.UserOperateDetail;
import com.crm.custinfo.service.IUserOperateDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 操作员分配明细Controller
 * 
 * @author ruoyi
 * @date 2024-01-17
 */
@RestController
@RequestMapping("/crmsys/operate_detail")
public class UserOperateDetailController extends BaseController
{
    @Autowired
    private IUserOperateDetailService userOperateDetailService;

    /**
     * 查询操作员分配明细列表
     */
    @PreAuthorize("@ss.hasPermi('crmsys:operate_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserOperateDetail userOperateDetail)
    {
        startPage();
        List<UserOperateDetail> list = userOperateDetailService.selectUserOperateDetailList(userOperateDetail);
        return getDataTable(list);
    }

    /**
     * 导出操作员分配明细列表
     */
    @PreAuthorize("@ss.hasPermi('crmsys:operate_detail:export')")
    @Log(title = "操作员分配明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserOperateDetail userOperateDetail)
    {
        List<UserOperateDetail> list = userOperateDetailService.selectUserOperateDetailList(userOperateDetail);
        ExcelUtil<UserOperateDetail> util = new ExcelUtil<UserOperateDetail>(UserOperateDetail.class);
        util.exportExcel(response, list, "操作员分配明细数据");
    }

    /**
     * 获取操作员分配明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('crmsys:operate_detail:query')")
    @GetMapping(value = "/{operId}")
    public AjaxResult getInfo(@PathVariable("operId") Long operId)
    {
        return success(userOperateDetailService.selectUserOperateDetailByOperId(operId));
    }

    /**
     * 新增操作员分配明细
     */
    @PreAuthorize("@ss.hasPermi('crmsys:operate_detail:add')")
    @Log(title = "操作员分配明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserOperateDetail userOperateDetail)
    {
        return toAjax(userOperateDetailService.insertUserOperateDetail(userOperateDetail));
    }

    /**
     * 修改操作员分配明细
     */
    @PreAuthorize("@ss.hasPermi('crmsys:operate_detail:edit')")
    @Log(title = "操作员分配明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserOperateDetail userOperateDetail)
    {
        return toAjax(userOperateDetailService.updateUserOperateDetail(userOperateDetail));
    }

    /**
     * 删除操作员分配明细
     */
    @PreAuthorize("@ss.hasPermi('crmsys:operate_detail:remove')")
    @Log(title = "操作员分配明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operIds}")
    public AjaxResult remove(@PathVariable Long[] operIds)
    {
        return toAjax(userOperateDetailService.deleteUserOperateDetailByOperIds(operIds));
    }
}
